const Shell = imports.gi.Shell;
const Main = imports.ui.main;
-const MessageTray = imports.ui.messageTray;
const Gettext = imports.gettext.domain('gnome-shell');
const _ = Gettext.gettext;
function _handleSpawnError(command, err) {
let title = _("Execution of '%s' failed:").format(command);
-
- let source = new MessageTray.SystemNotificationSource();
- Main.messageTray.add(source);
- let notification = new MessageTray.Notification(source, title, err.message);
- notification.setTransient(true);
- source.notify(notification);
+ Main.notifyProblem(title, err.message);
}
// killall:
global.logError = _logError;
global.log = _logDebug;
+ // Chain up async errors reported from C
+ global.connect('notify-error', function (global, msg, detail) { notifyError(msg, detail); });
+
Gio.DesktopAppInfo.set_desktop_env('GNOME');
shellDBusService = new ShellDBus.GnomeShell();
themeContext.set_theme (theme);
}
+/**
+ * notifyError:
+ * @msg: An error message
+ * @details: Additional information
+ *
+ * See shell_global_notify_problem().
+ */
+function notifyError(msg, details) {
+ // Also print to stderr so it's logged somewhere
+ if (details)
+ log("error: " + msg + ": " + details);
+ else
+ log("error: " + msg)
+
+ let source = new MessageTray.SystemNotificationSource();
+ messageTray.add(source);
+ let notification = new MessageTray.Notification(source, msg, details);
+ notification.setTransient(true);
+ source.notify(notification);
+}
+
/**
* _log:
* @category: string message type ('info', 'error')
#include <gdk/gdkx.h>
#include <gio/gio.h>
#include <gjs/gjs-module.h>
+#include <girepository.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
XDND_POSITION_CHANGED,
XDND_LEAVE,
XDND_ENTER,
+ NOTIFY_ERROR,
LAST_SIGNAL
};
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ shell_global_signals[NOTIFY_ERROR] =
+ g_signal_new ("notify-error",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ gi_cclosure_marshal_generic,
+ G_TYPE_NONE, 2,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
+
g_object_class_install_property (gobject_class,
PROP_OVERLAY_GROUP,
g_param_spec_object ("overlay-group",
gjs_context_maybe_gc (global->js_context);
}
+/**
+ * shell_global_notify_error:
+ * @global: a #ShellGlobal
+ * @msg: Error message
+ * @details: Error details
+ *
+ * Show a system error notification. Use this function
+ * when a user-initiated action results in a non-fatal problem
+ * from causes that may not be under system control. For
+ * example, an application crash.
+ */
+void
+shell_global_notify_error (ShellGlobal *global,
+ const char *msg,
+ const char *details)
+{
+ g_signal_emit_by_name (global, "notify-error", msg, details);
+}
+
static void
grab_notify (GtkWidget *widget, gboolean was_grabbed, gpointer user_data)
{
void shell_global_cancel_theme_sound (ShellGlobal *global,
guint id);
+
+void shell_global_notify_error (ShellGlobal *global,
+ const char *msg,
+ const char *details);
+
void shell_global_init_xdnd (ShellGlobal *global);
typedef void (*ShellGetTpContactCb) (TpConnection *connection,